﻿using ERPEF;
using ERPEF.Model;
using Microsoft.EntityFrameworkCore;
using S4Project.Model;
using System.Reflection.Emit;

namespace S4Project
{
    public class MyDbContext : DbContext
    {
        public string conStr = "Data Source=rm-cn-em93outyl0004m9o.sqlserver.rds.aliyuncs.com, 1433;Initial Catalog=ERP_Project;User ID=k123_123h;Password=Qw123456;Encrypt=False;";

        public MyDbContext(DbContextOptions<MyDbContext> options) : base(options)
        {
            //读取program
        }
        protected override void OnConfiguring(DbContextOptionsBuilder optionsBuilder)
        {
           
            optionsBuilder.LogTo(msg =>
            {
                if (!msg.Contains("CommandExecuting"))
                {
                    return;
                }
                Console.WriteLine(msg);

            });
        }
        protected override void OnModelCreating(ModelBuilder modelBuilder)
        {
            modelBuilder.ApplyConfigurationsFromAssembly(this.GetType().Assembly);

            modelBuilder.Entity<inv_Storage>() 
       .ToTable(tb => tb.HasTrigger("SomeTrigger")); 

            modelBuilder.Entity<inv_other_outbound>() 
      .ToTable(tb => tb.HasTrigger("SomeTrigger2")); 
        }
        public DbSet<bs_Warehouse> bs_Warehouse { get; set; } //仓库
        public DbSet<bs_employee> bs_Employee { get; set; }  //员工

        public DbSet<bs_dict_data> bs_dict_data { get; set; }

        public DbSet<bs_dict_image> bs_dict_image { get; set; }
        public DbSet<bs_Inventory_Alerts> bs_Inventory_Alerts { get; set; } //库存预警
        public DbSet<sal_sales_orders> sal_sales_orders { get; set; } //销售订单
        public DbSet<sal_orders> sal_orders { get; set; } //销售订单从表
        public DbSet<sal_sales_Out> sal_sales_Out { get; set; } //销售出库主表
        public DbSet<sal_sales_Out_C> sal_sales_Out_C { get; set; } //销售出库从表
        public DbSet<sal_sales_Return> sal_sales_Return { get; set; } //销售退货
        public DbSet<sal_sales_Return_C> sal_sales_Return_C { get; set; } //销售退货从表


        public DbSet<bs_client> bs_Client { get; set; } //客户

        public DbSet<inv_Storage> inv_Storage { get; set; }//其他入库

        public DbSet<inv_goods_inventory> inv_goods_inventory { get; set; }//库存

        public DbSet<inv_other_outbound> inv_other_outbound { get; set; }//其他出库

       
        //采购管理
        public DbSet<pur_Purchase_Order> pur_Purchase_Order { get; set; }//采购订单
        public DbSet<pur_Purchase_From> pur_Purchase_From { get; set; }//采购订单从表
        public DbSet<pur_Chase_Receipt> pur_Chase_Receipt { get; set; }//采购入库
        public DbSet<pur_Chase_From> pur_Chase_From { get; set; }//采购入库从表
        public DbSet<pur_Sales_Return> pur_Sales_Return { get; set; }//采购退货
        public DbSet<pur_Sales_From> pur_Sales_From { get; set; }//采购退货从表

        public DbSet<bs_vendor> bs_Vendor { get; set; }  //供应商

        public DbSet<bs_model> bs_Model { get; set; }  //产品型号

        public DbSet<bs_Model_From> bs_Model_From { get; set; } //产品型号从表

        public DbSet<pro_orders> pro_orders { get; set; }//生产订单列表

        public DbSet<pro_ntity> pro_ntity { get; set; } //生产订单列表从表

        public DbSet<pro_warehousing> pro_warehousing { get; set; } //生产人库订单列表

        public DbSet<pro_warehousing_from> pro_warehousing_from { get; set; } //生产人库订单列表从表

        public DbSet<inv_WarehouseInven> inv_WarehouseInven { get; set; } //仓库盘点主表
        public DbSet<inv_WarehouseInven_C> inv_WarehouseInven_C { get; set; } //仓库盘点从表


        public DbSet<UserRoles> UserRoles { get; set; } //用户角色表
        public DbSet<RolesJurisdiction> RolesJurisdiction { get; set; } //角色权限表
        public DbSet<Roles> Roles { get; set; } //角色表
        public DbSet<Jurisdiction> Jurisdiction { get; set; } //权限表
        public DbSet<User> User { get; set; } //用户表

        public DbSet<CeBianlan> CeBianlan { get; set; }

        public DbSet<rolesuser> rolesusers { get; set; }
        public DbSet<Trees> Trees { get; set; }
    }
}
